<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> --%>
<%@ include file="header.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>	
<body>
	<form action="${path}/user?method=insert" method="post">
	
		用户名: <input type="text" name="name"/><br/>
		密码: <input type="password" name="password"/><br/>
		邮箱: <input type="text" name="email"/><br/>
		年龄: <input type="text" name="age"/><br/>
		部门: <%-- <select name="departmentId">
				<c:forEach items="${list}" var="department">
					<option value="${department.id}">${department.name}</option>
				</c:forEach>
			  </select> --%>
			  <select id="departmentId" name="departmentId">
			      <option>---请选择---</option>
			  </select>
			  <br/>
		 <input type="submit" value="添加"/><br/>
		 
		 <script type="text/javascript">
		     $(function() {
		    	 $.post('${path}/department?method=selectAllByJson',
		    	     function(jsonObj) {
		    		     console.log(jsonObj);
		    		     $(jsonObj).each(function() {
		    		    	 $('#departmentId').append('<option value="'+this.id'">'+this.name+'</option>')
		    		     });
		    	 },
		    	 'json'
		     );
		 });
		     
		 </script>
	</form>
</body>
</html>